package com.example.service;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OllamaClientService {

    private final ChatClient chatClient;

    @Autowired
    public OllamaClientService(ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    public String simpleChat(String message) {
        // 使用流畅的 API 调用 Ollama
        return chatClient.prompt().user(message).call().content();
    }

    public String chatWithSystemPrompt(String message) {
        // 添加系统提示
        return chatClient.prompt()
                .system("你是一个专业助手，用简洁的语言回答问题。")
                .user(message)
                .call()
                .content();
    }
}
